package com.quark.framework.database;

import com.quark.framework.configuration.QuarkConfigBase;

public class QuarkDBConfiguration extends QuarkConfigBase {

	public String dbUserName = "root";
	public String dbUserPass = "";	
	public String dbServerAddr = "";
	public String dbServerPort = "3306";
	public String dbDatabase = "";
	public String dbUseUnicode = "true";
	public Integer dbMaxConnection = 10;
	public Integer dbIncrementCount = 2;
	public Integer dbFullThredhold = 10;
	public String dbCharacterEncoding = "GB2312";
	public String[] dbTablePostfix = new String[0];
	
	public QuarkDBConfiguration()
	{	
	}
	
	public String createConnectionUrl()
	{
		return "jdbc:mysql://" + dbServerAddr + ":" + dbServerPort + "/" + dbDatabase + 
		"?useUnicode=" + dbUseUnicode + "&characterEncoding=" + dbCharacterEncoding;
	}
	
	public String getDBTablePostFix(Integer index)
	{
		if(0 <= index && index < dbTablePostfix.length)
		{
			return dbTablePostfix[index];
		}
		return dbTablePostfix[1];
	}
}
